// basic_types.c
#include <node_api.h>

napi_value getDouble(napi_env env, napi_callback_info info)
{
    napi_value result;
    napi_create_double(env, 3.14159, &result);
    return result;
}

napi_value getHello(napi_env env, napi_callback_info info)
{
    napi_value result;
    napi_create_string_utf8(env, "Hello from C!", NAPI_AUTO_LENGTH, &result);
    return result;
}

napi_value getBool(napi_env env, napi_callback_info info)
{
    napi_value result;
    napi_get_boolean(env, true, &result);
    return result;
}

napi_value GetNull(napi_env env, napi_callback_info info)
{
    napi_value result;
    napi_get_null(env, &result);
    return result;
}

napi_value GetUndefined(napi_env env, napi_callback_info info)
{
    napi_value result;
    napi_get_undefined(env, &result);
    return result;
}

napi_value Init(napi_env env, napi_value exports)
{
    napi_property_descriptor descs[] = {{"doubleValue", NULL, getDouble, NULL, NULL, NULL, napi_default, NULL},
        {"stringValue", NULL, getHello, NULL, NULL, NULL, napi_default, NULL},
        {"boolValue", NULL, getBool, NULL, NULL, NULL, napi_default, NULL},
        {"nullValue", NULL, GetNull, NULL, NULL, NULL, napi_default, NULL},
        {"undefinedValue", NULL, GetUndefined, NULL, NULL, NULL, napi_default, NULL}};
    napi_define_properties(env, exports, 5, descs);
    napi_value key, value;
    napi_create_string_utf8(env, "str", NAPI_AUTO_LENGTH, &key);
    napi_create_string_utf8(env, "a string", NAPI_AUTO_LENGTH, &value);
    napi_set_property(env, exports, key, value);
    return exports;
}

NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)